#include "list.h"

List::List() {
	head = 0;
	tail = 0;
}

void List::InsertNode( Circle *circle ) {
	if( head == 0 ) {
		circle->previous = 0;
		circle->next = 0;
		head = circle;
		tail = circle;
	}
	else {
		Circle *old_tail = tail;
		tail = circle;
		old_tail->next = circle;
		circle->previous = old_tail;
		circle->next = 0;
	}	
}

void List::DeleteNode( Circle *circle ) {
	if( head == 0 && tail == 0 ) {
		return;
	}
	else if( circle->previous != 0 ) {
		circle->previous->next = circle->next;
	}
	else {
		head = circle->next;
	}

	if( circle->next != 0 ) {
		circle->next->previous = circle->previous;
	}
	else {
		tail = circle->previous;
	}
	
	delete circle;
}
